﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Spore.Validator
{
    /// <summary>
    /// 一些基于正则表达式的验证器
    /// </summary>
   public class ValidatorDefaults
    {
       static string emailString=@"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$";
       static ValidatorRegex validatorEmail = new ValidatorRegex(emailString,"您的输入不符合Email地址格式");
       /// <summary>
       /// Email格式验证器
       /// </summary>
       public static IValidator Email
       {
           get { return validatorEmail; }
       }

       static string urlstr = @"^http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?$";
       static ValidatorRegex validatorUrl = new ValidatorRegex(urlstr, "您的输入不符合URL格式");
       /// <summary>
       /// URL验证器
       /// </summary>
       public static IValidator URL
       {
           get { return validatorUrl; }
       }

       static string phoneNum = @"(^(\d{2,4}[-_－—]?)?\d{3,8}([-_－—]?\d{3,8})?([-_－—]?\d{1,7})?$)|(^0?1[35]\d{9}$)
";
       static ValidatorRegex validatorPhone = new ValidatorRegex(phoneNum,"您的输入不符合电话号码格式");
       /// <summary>
       /// 电话号码验证器
       /// </summary>
       public static IValidator Phone
       {
           get { return validatorPhone; }
       }

       /// <summary>
       /// 非空验证器
       /// </summary>
       public static IValidator NotNull
       {
           get { return ValidatorNotNull.Default; }
       }

       /// <summary>
       /// 整数验证器
       /// </summary>
       public static IValidator Integer
       {
           get { return ValidatorInteger.Default; }
       }

       /// <summary>
       /// Double型验证器
       /// </summary>
       public static IValidator Double
       {
           get { return ValidatorDouble.Default; }
       }

       /// <summary>
       /// Float验证器
       /// </summary>
       public static IValidator Float
       {
           get { return ValidatorFloat.Default; }
       }

       /// <summary>
       /// IP地址验证器
       /// </summary>
       public static IValidator IPAddress
       {
           get { return ValidatorIPAddress.Default; }
       }

       /// <summary>
       /// 时间格式验证器
       /// </summary>
       public static IValidator DateTime
       {
           get { return ValidatorIsDate.Default; }
       }
       
    }

}
